import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Arrays;

public class DictionaryLoader {
    
    public static final String DICTIONARY_PATH = "dictionary.txt";
    
    public static String[] loadDictionary() {
	
	try {
	    Scanner s = new Scanner(new BufferedReader(new FileReader(DICTIONARY_PATH)));
	    List<String> dictionary = new ArrayList<String>();
	    
	    while (s.hasNext()) {
		dictionary.add(s.next().toLowerCase());
	    }
	    
	    String[] a = dictionary.toArray(new String[0]);
	    Arrays.sort(a);
	    return a;
	    
	} catch (FileNotFoundException e) {
	    System.err.println("Standard dictionary file " + DICTIONARY_PATH + " missing");
	    return new String[0];
	}
    }
}
